Testing some geometry routines in C++
[andmenj-acm.git] / 11577 - Letter frequency / 11577.cpp
blob51ca380a83eff6b608a843406e6cfad1c144e532
1 /*
2 Problem:
3 Andrés Mejía-Posada (andmej@gmail.com)
4 */
5 using namespace std;
6 #include <algorithm>
7 #include <iostream>
8 #include <iterator>
9 #include <sstream>
10 #include <fstream>
11 #include <numeric>
12 #include <cassert>
13 #include <climits>
14 #include <cstdlib>
15 #include <cstring>
16 #include <string>
17 #include <cstdio>
18 #include <vector>
19 #include <cmath>
20 #include <queue>
21 #include <deque>
22 #include <stack>
23 #include <list>
24 #include <map>
25 #include <set>
27 #define foreach(x, v) for (typeof (v).begin() x = (v).begin(); x != (v).end(); ++x)
28 #define For(i, a, b) for (int i=(a); i<(b); ++i)
29 #define D(x) cout << #x " is " << x << endl
32 int main(){
33 int n;
34 cin >> n;
35 string s;
36 getline(cin, s);
37 while (n--){
38 map<char, int> f;
39 getline(cin, s);
40 for (int i=0; i<s.size(); ++i){
41 s[i] = tolower(s[i]);
42 if (isalpha(s[i])) f[s[i]]++;
44 int best = 0;
45 string ans = "*";
46 for (map<char, int>::iterator i = f.begin(); i != f.end(); ++i){
47 if(i->second > best){
48 best = i->second;
49 ans = string(1, i->first);
51 else if (i->second == best){
52 ans += i->first;
55 sort(ans.begin(), ans.end());
56 cout << ans << endl;
59 return 0;